<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box"></div>
    <script>
        //求两个时间的时间差
        var date1 = new Date('2019/12/12 12:12:12');
        var date2 = new Date('2020/06/19 19:45:10');

        var time1 = date1.getTime();
        var time2 = date2.getTime();

        var res = Math.abs(time1 - time2);
        console.log(res);
        
        var day = parseInt(res / 1000 / 60 / 60 / 24);
        console.log(day);
        var hours = parseInt((res / 1000 / 60 / 60 ) % 24);
        console.log(hours);
        var min = parseInt((res / 1000 / 60 ) % 60);
        console.log(min);
        var seconds = parseInt((res / 1000) % 60);
        console.log(seconds);
        console.log('相差 ' + day + ' 天 ' + hours + ' 小时 ' + min + ' 分钟 ' + seconds + ' 秒');

    </script>
</body>
</html>